package com.example.service.impl;

import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.example.domain.Userj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.mapper.UsersMapper;
import com.example.domain.Users;
import com.example.service.IUsersService;

/**
 * 用户信息Service业务层处理
 *
 * @author ruoyi
 * @date 2023-04-13
 */
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper,Users> implements IUsersService
{
    @Autowired
    private UsersMapper usersMapper;

    /**
     * 查询用户信息
     *
     * @param usersId 用户信息主键
     * @return 用户信息
     */
    @Override
    public Users selectUsersByUsersId(Integer usersId)
    {
        return usersMapper.selectUsersByUsersId(usersId);
    }

    /**
     * 查询用户信息列表
     *
     * @param users 用户信息
     * @return 用户信息
     */
    @Override
    public List<Users> selectUsersList(Users users)
    {
        return usersMapper.selectUsersList(users);
    }

    /**
     * 新增用户信息
     *
     * @param users 用户信息
     * @return 结果
     */
    @Override
    public int insertUsers(Users users)
    {

        return usersMapper.insertUsers(users);
    }

    /**
     * 修改用户信息
     *
     * @param users 用户信息
     * @return 结果
     */
    @Override
    public int updateUsers(Users users)
    {

        return usersMapper.updateUsers(users);
    }

    /**
     * 批量删除用户信息
     *
     * @param usersIds 需要删除的用户信息主键
     * @return 结果
     */
    @Override
    public int deleteUsersByUsersIds(Integer[] usersIds)
    {
        return usersMapper.deleteUsersByUsersIds(usersIds);
    }

    /**
     * 删除用户信息信息
     *
     * @param usersId 用户信息主键
     * @return 结果
     */
    @Override
    public int deleteUsersByUsersId(Integer usersId)
    {
        return usersMapper.deleteUsersByUsersId(usersId);
    }

    @Override
    public Users login(Userj use) {

            QueryWrapper<Users> queryWrapper=new QueryWrapper<>();
            queryWrapper.eq("user_phone",use.getUserPhone());
            queryWrapper.eq("password",use.getPassword());
            Users users = baseMapper.selectOne(queryWrapper);
            return users;

    }

    @Override
    public Integer adduser(Users use) {
        use.setCreateTime(new Date());
        int b = baseMapper.insertUsers(use);
        return b;
    }

    @Override
    public Users selectphone(String phone) {
        QueryWrapper<Users> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_phone",phone);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public int inser(Users use) {
        QueryWrapper queryWrapper=new QueryWrapper<>();

        return 2;
    }
}
